/**
 * Licensed under the Apache License Version 2.0.
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package net.interknit.knitter.cg.template;

import java.util.Collection;
import java.util.Hashtable;
import java.util.Map;

/**
 *
 */
public class ParameterBeanTemplateHolder
{
	private static ParameterBeanTemplateHolder instance;

	public static ParameterBeanTemplateHolder getInstance()
	{
		return instance != null ? instance : (instance = new ParameterBeanTemplateHolder());
	}

	private final Map<String, ParameterBeanTemplate> paramBeanTemplates = new Hashtable<String, ParameterBeanTemplate>();

	private ParameterBeanTemplateHolder()
	{
		;
	}

	public Collection<ParameterBeanTemplate> getAll()
	{
		return paramBeanTemplates.values();
	}

	public ParameterBeanTemplate create(String parameterBeanName)
	{
		ParameterBeanTemplate bean = new ParameterBeanTemplate();
		paramBeanTemplates.put(parameterBeanName, bean.setParameterBeanName(parameterBeanName));

		return bean;
	}

	public ParameterBeanTemplate get(String parameterBeanName)
	{
		return paramBeanTemplates.get(parameterBeanName);
	}

	public void clear()
	{
		paramBeanTemplates.clear();
	}
}
